﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Start
{
    class Program
    {
        static Random next = new Random();
        static void Main(string[] args)
        {
            //Console.BufferHeight = Console.WindowHeight = 60;
            //Console.BufferWidth = Console.BufferWidth = 20;

            int n = 9;
            // printing S
            PrintS(n);
            //print T
            PrintT(n);
            // printing a
            PrintA(n);
            // printing r
            PrintR(n);
            //print T
            PrintT(n);
        }
        static void PrintS(int n)
        {
            string[,] matrix = new string[n, (n - 2)];

            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                for (int col = 0; col < matrix.GetLength(1); col++)
                {
                    if (((row==0 || row== n/2 || row== matrix.GetLength(0)-1) && (col>0 && col < matrix.GetLength(1)- 1)) || (col ==0 && row>0&& row<n/2) || (col== matrix.GetLength(1)-1 && row<matrix.GetLength(0) - 1 &&row >n/2))                  
                    {
                        int num = next.Next(0, 10);
                        Console.Write(num);
                    }
                    else
                    {
                        Console.Write(" ");
                    }

                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
        static void PrintT(int n)
        {
            string[,] matrix = new string[n, (n - 2)];

            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                for (int col = 0; col < matrix.GetLength(1); col++)
                {
                    if (row==0 || col== (n-2)/2)
                    {
                        int num = next.Next(0, 10);
                        Console.Write(num);
                    }
                    else
                    {
                        Console.Write(" ");
                    }

                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }

        static void PrintA(int n)
        {
            string[,] matrix = new string[n, (n - 2)];

            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                for (int col = 0; col < matrix.GetLength(1); col++)
                {
                    if (row + col == (n - 2) / 2 || col - row == (n - 2) / 2 || (col == 0 && row >= n / 2) || (col == matrix.GetLength(1) - 1 && row >= n / 2) || row == n / 2)
                    {
                        int num = next.Next(0, 10);
                        Console.Write(num);
                    }
                    else
                    {
                        Console.Write(" ");
                    }

                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
 
        static void PrintR(int n)
        {
            string[,] matrix = new string[n, (n - 2)];

            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                for (int col = 0; col < matrix.GetLength(1); col++)
                {
                    if (col == 0 || ((row == 0 || row == n / 2) && col < matrix.GetLength(1) - 1) || (col == matrix.GetLength(1) - 1 && row >= 1 && row < n / 2) || (row > n / 2 && col >= (n - 2) / 2 && row - col == 2))
                    {
                        int num = next.Next(0, 10);
                        Console.Write(num);
                    }
                    else
                    {
                        Console.Write(" ");
                    }

                }
                Console.WriteLine();
            }
            Console.WriteLine();

        }
    }
}
